e2f10b
@@ -22,6 +22,7 @@
 
 import org.apache.hadoop.hive.common.JavaUtils;
 import org.apache.hadoop.hive.ql.exec.Description;
+import org.apache.hadoop.hive.ql.exec.FunctionRegistry;
 import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
 import org.apache.hadoop.hive.ql.exec.UDFArgumentLengthException;
 import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException;
@@ -33,6 +34,8 @@
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory;
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.StringObjectInspector;
 import org.apache.hadoop.util.ReflectionUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * A simple generic udf to call java static functions via reflection.
@@ -42,6 +45,7 @@
   extended = "Use this UDF to call Java methods by matching the argument signature\n")
 @UDFType(deterministic = false)
 public class GenericUDFReflect extends AbstractGenericUDFReflect {
+  private static final Logger LOG = LoggerFactory.getLogger(GenericUDFReflect.class);
 
   private transient StringObjectInspector inputClassNameOI;
   private transient StringObjectInspector inputMethodNameOI;
@@ -105,13 +109,18 @@
public Object evaluate(DeferredObject[] arguments) throws HiveException {
       try {
         c = JavaUtils.loadClass(classNameString);
       } catch (ClassNotFoundException ex) {
-        throw new HiveException("UDFReflect evaluate ", ex);
+        throw new HiveException(String.format("UDFReflect evaluate error while loading class %s", classNameString), ex);
       }
       try {
         o = null;
         o = ReflectionUtils.newInstance(c, null);
       } catch (Exception e) {
-        // ignored
+        if (e.getCause() instanceof NoSuchMethodException){
+          // still could be okay while using a static method of a class that hasn't got a default/parameterless constructor
+          LOG.trace("ignoring NoSuchMethodException while instantiating class", e);
+        }else{
+          throw new HiveException(String.format("UDFReflect evaluate error while instantiating class %s", classNameString), e);
+        }
       }
       classNameChanged = true;
     }
